package cn.iocoder.yudao.module.system.mq.producer.product;

import cn.iocoder.yudao.module.system.mq.message.product.ProductSendMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 系统产品购买后的异步通知
 */
@Slf4j
@Component
public class ProductProducer {

    @Resource
    private ApplicationContext applicationContext;

    /**
     * 发送 {@link ProductSendMessage} 消息
     *

     */
    public void sendProductMessage(String code, Integer num, Integer expireTime, Long tenantId, Long bizId) {
        ProductSendMessage message = new ProductSendMessage().setCode(code).setNum(num).setExpireTime(expireTime).setTenantId(tenantId).setBizId(bizId);
        applicationContext.publishEvent(message);
    }


}
